<?php
	class Account extends CI_Controller
	{
		public function __construct()
		{
			parent::__construct();
			if (!isset($_SESSION)) {
			    session_start();
			    session_regenerate_id();
			}
			$this->load->helper("url");
			
		}
		public function index()
		{
			$type=-1;
			if(isset($_REQUEST['type']))
				$type=$_REQUEST['type'];
			$data=array();
			$data['type']=$type;
			$data['action']='list_account';
			$this->load->model("maccount");
			if(isset($_REQUEST['m_name'])){
				$m_name=$_REQUEST['m_name'];
				$m_start=$_REQUEST['m_start'];
				$m_end=$_REQUEST['m_end'];
				$data['list_account']=$this->maccount->list_account_search($m_start,$m_end,$m_name);
			}else{
				$data['list_account']=$this->maccount->list_account($type);
			}
			$this->load->view("account_template", $data);
			
		}
		public function acc_detail()
		{
			$aid=0;
			if(isset($_REQUEST['aid']))
				$aid=$_REQUEST['aid'];
			$data=array();
			$data['aid']=$aid;
			$data['action']='acc_detail';
			$this->load->model("maccount");
			
			$data['account']=$this->maccount->acc_detail($aid);
			
			$this->load->view("account_template", $data);
			
		}
	public function close_account()
		{
			$aid=0;
			if(isset($_REQUEST['aid']))
				$aid=$_REQUEST['aid'];
			$data=array();
			$this->load->model("maccount");
			$this->maccount->close_account($aid);
		}
	}
?>